<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center searchye_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between flex-sub searchye_fd0_0'>
					<text class='fu-iconfont2  searchye_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
						data-url="1">&#xE794;</text>
					<view class='flex flex-wrap align-center flex-sub searchye_fd0_0_c1'>
						<image class='searchye_fd0_0_c1_c0' mode="aspectFit" :src='STATIC_URL+"145.png"'></image>
						<benben-input class='flex-sub searchye_fd0_0_c1_c1' type="text" :placeholder="`请输入关键字搜索`"
							confirm-type="done" :maxlength="-1"
							placeholder-style="color:rgba(153, 153, 153, 1);font-size:28rpx"
							@input="oninput"
							@confirm="addSearchHistoryFunc()" v-model="keyword" />
						<image class='searchye_fd0_0_c1_c2' mode="aspectFit" :src='STATIC_URL+"149.png"'
							@tap.stop="clearBoxContentFunc()" v-if=" keyword!=''"></image>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---搜索记录flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout searchye_flex_1">
				<view class='flex flex-wrap align-center searchye_fd1_0'>
					<image class='searchye_fd1_0_c0' mode="aspectFit" :src='STATIC_URL+"147.png"'></image>
					<text class='searchye_fd1_0_c1'>历史搜索</text>
					<image class='self-end searchye_fd1_0_c2' mode="aspectFill" :src='STATIC_URL+"148.png"'
						@tap.stop="popupShow1661481796822=true"></image>
				</view>
				<view class='flex flex-wrap align-center searchye_fd1_1' v-if=" appSearchHistory.length>=0">
					<template v-for='(item,key0) in appSearchHistory'>
						<view class='flex flex-wrap align-center searchye_fd1_1_c0' @tap.stop="handleJumpDiy"
							data-type="navigateTo"
							:data-url="`/pages/homePage/recommendCommodityList/recommendCommodityList?keyword=${item.name}`"
							@longpress="handleLongpressFunc(key0)" :key='key0'>
							<text class='searchye_fd1_1_c0_c0'>{{item.name}}</text>
							<image class='searchye_fd1_1_c0_c1' mode="aspectFit" :src='STATIC_URL+"149.png"'
								@tap.stop="deleteSearchHistoryFunc(item.name)" v-if=" key0==removeIndex"></image>
						</view>
					</template>

				</view>
				<text class='searchye_fd1_2' v-if=" appSearchHistory.length<=0">暂无历史记录</text>
			</view>

			<!---搜索记录flex布局结束-->
			<benben-popup v-model="popupShow1661481796822" :mask="true" :mask-close-able="true" mode='center'>
				<!---删除历史记录弹窗flex布局开始-->
				<view class="flex flex-direction flex-wrap align-center searchye_flex_2">
					<text class='searchye_fd2_0'>确定删除历史记录？</text>
					<view class='flex flex-wrap align-center justify-center searchye_fd2_1'>
						<button class='searchye_fd2_1_c0' @tap.stop="popupShow1661481796822=false">取消</button>
						<button class='searchye_fd2_1_c1' @tap.stop="emptySearchHistoryFunc()">确定</button>
					</view>
				</view>

				<!---删除历史记录弹窗flex布局结束-->

			</benben-popup>
			<!---flex布局flex布局开始-->
			<view class="flex benben-flex-layout flex-wrap align-center" v-if="courseTitle.length > 0">
				<view class='flex flex-wrap align-center flex-sub searchye_fd3_0' v-for="(item, index) in courseTitle" :key="index" @tap.stop="handleJumpDiy" data-type="navigateTo" :data-url="`/pages/homePage/courseDetail/courseDetail?id=${item.aid}`">
					<image class='searchye_fd3_0_c0' mode="aspectFit" :src='STATIC_URL+"145.png"'></image>
					<view class='flex flex-wrap align-center justify-between flex-sub searchye_fd3_0_c1'>
						<text class='searchye_fd3_0_c1_c0'>{{item.title}}</text>
						<image class='searchye_fd3_0_c0' mode="aspectFit" :src='STATIC_URL+"150.png"'></image>
					</view>
				</view>
			</view>

			<!---flex布局flex布局结束-->


		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},


		data() {
			return {
				"popupShow1661481796822": false,
				"dataLists": [],
				"removeIndex": -1,
				"keyList": [],
				"keyword": "",
				"courseTitle": [],
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},
			appSearchHistory() { // 搜索历史
				return this.$store.state.appSearchHistory
			}
		},
		watch: {},
		onLoad(options) {

		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//搜索
			// async searchForFunc() {
			// 	//请求方法
			// 	//数据验证

			// 	let data = await this.$api.get(, {

			// 	});

			// 	if (data.data.code != 1) {
			// 		this.$message.info(data.data.msg);
			// 		return
			// 	}



			// },
			oninput() {
				this.getCourseTitle();
			},
			getCourseTitle() {
				this.$api.post(global.apiUrls.post65deae2aa0f1e, {
					keyword: this.keyword
				}).then(res => {
					// console.log(res);
					if (res.data.code == 1) {
						this.courseTitle = res.data.data;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			//长按事件
			handleLongpressFunc(index) {
				this.removeIndex = index;
			},
			//添加搜索历史
			addSearchHistoryFunc() {
				this.$store.commit('appSearchHistoryAdd', {
					"name": this.keyword
				})
				this.$urouter.navigateTo(
					`/pages/homePage/recommendCommodityList/recommendCommodityList?keyword=${this.keyword}`);
			},
			//删除搜索历史
			deleteSearchHistoryFunc(name) {
				this.$store.commit('appSearchHistoryDel', {
					"name": name
				})
			},
			//清空搜索记录
			emptySearchHistoryFunc() {
				this.$store.commit('appSearchHistoryClean', '')
				this.popupShow1661481796822 = false;
			},
			//清空输入框内容
			clearBoxContentFunc() {
				this.keyword = '';
				this.courseTitle = [];
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: url(image-path('137.png')) no-repeat;
		background-size: 100% auto;
	}

	.searchye_flex_0 {
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
	}

	.searchye_fd0_0_c1_c2 {
		width: 36rpx;
		height: 36rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.searchye_fd0_0_c1_c1 {
		margin: 0rpx 0rpx 0rpx 16rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333;
		transform: translateY(3rpx);
	}

	.searchye_fd0_0_c1_c0 {
		width: 48rpx;
		height: 48rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.searchye_fd0_0_c1 {
		background: rgba(249, 249, 249, 1);
		background-size: 100% auto !important;
		border-radius: 34rpx 34rpx 34rpx 34rpx;
		width: 574rpx;
		height: 64rpx;
		margin: 0rpx 0rpx 0rpx 24rpx;
		padding: 0rpx 24rpx 0rpx 24rpx;
	}

	.searchye_fd0_0_c0 {
		font-size: 36rpx;
		color: #333;
		font-weight: 500;
	}

	.searchye_fd0_0 {
		margin: 16rpx 32rpx 0rpx 32rpx;
	}

	.searchye_flex_1 {
		padding: 0rpx 0rpx 0rpx 0rpx;
	}

	.searchye_fd1_2 {
		font-size: 24rpx;
		font-weight: 400;
		color: #666666;
		margin: 0rpx 0rpx 32rpx 040rpx;
	}

	.searchye_fd1_1_c0_c1 {
		width: 36rpx;
		height: 36rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 0rpx 0rpx 8rpx;
	}

	.searchye_fd1_1_c0_c0 {
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(102, 102, 102, 1);
	}

	.searchye_fd1_1_c0 {
		background: var(--benbenbgColor0);
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		background-size: 100% auto !important;
		padding: 8rpx 24rpx 8rpx 24rpx;
		margin: 0rpx 24rpx 24rpx 0rpx;
	}

	.searchye_fd1_1 {
		padding: 0rpx 36rpx 0rpx 36rpx;
	}

	.searchye_fd1_0_c2 {
		width: 48rpx;
		height: 48rpx;
		margin: 0rpx 0rpx 0rpx auto;
	}

	.searchye_fd1_0_c1 {
		font-size: 28rpx;
		font-weight: 500;
		color: rgba(51, 51, 51, 1);
	}

	.searchye_fd1_0_c0 {
		width: 48rpx;
		height: 48rpx;
		border-radius: 17rpx 17rpx 17rpx 17rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.searchye_fd1_0 {
		padding: 24rpx 0rpx 32rpx 0rpx;
		margin: 0rpx 36rpx 0rpx 36rpx;
	}

	.searchye_flex_2 {
		background: #fff;
		background-size: #eee;
		border-radius: 25rpx 25rpx 25rpx 25rpx;
		padding: 40rpx 0rpx 0rpx 0rpx;
		width: 580rpx;
	}

	.searchye_fd2_1_c1 {
		background: #E60012;
		border-radius: 16rpx;
		font-size: 28rpx;
		color: rgba(255, 255, 255, 1);
		width: 254rpx;
		height: 80rpx;
		line-height: 80rpx;
		margin: 0rpx 0rpx 0rpx 12rpx;
	}

	.searchye_fd2_1_c0 {
		background: #F5F5F5;
		border-radius: 16rpx;
		font-size: 28rpx;
		color: rgba(102, 102, 102, 1);
		height: 80rpx;
		line-height: 80rpx;
		width: 254rpx;
		margin: 0rpx 12rpx 0rpx 0rpx;
	}

	.searchye_fd2_1 {
		padding: 0rpx 0rpx 32rpx 0rpx;
	}

	.searchye_fd2_0 {
		font-size: 32rpx;
		font-weight: 400;
		line-height: 52rpx;
		color: #333333;
		margin: 40rpx 0rpx 60rpx 0rpx;
	}

	.searchye_fd3_0_c1_c0 {
		font-size: 28rpx;
		color: #333;
	}

	.searchye_fd3_0_c1 {
		border-bottom: 1px solid rgba(226, 226, 226, 1);
		margin: 0rpx 0rpx 0rpx 10rpx;
		padding: 20rpx 36rpx 20rpx 0rpx;
	}

	.searchye_fd3_0_c0 {
		width: 48rpx;
		height: 48rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.searchye_fd3_0 {
		padding: 0rpx 0rpx 0rpx 36rpx;
	}
</style>